package com.tiancheng.trade.settlement.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

/**
 * 支付场景枚举
 *
 * @author supeicheng
 * @date 2024/4/2
 */
@Getter
@AllArgsConstructor
public enum PaySceneEnum implements BaseEnum<String> {

    // app中支付
    APP("app", "app"),
    // 微信小程序中支付
    MINIAPP("miniapp", "miniapp"),
    // h5中支付
    H5("H5", "H5"),
    // 微信公众号
    WXAPP("wxapp", "wxapp"),
    // web端支付
    PCWEB("pcweb", "pcweb"),
    // 刷脸支付
    FACESWIPING("face-swiping", "face-swiping"),
    // 扫码支付
    SCAN("scan", "scan"),
    // 云闪付小程序
    UNION_MINI("union_mini", "union_mini");

    private String code;
    private String desc;

    public static String getDesc(String code) {
        Optional<PaySceneEnum> found = Arrays.stream(PaySceneEnum.values()).filter(c -> StringUtils.equalsIgnoreCase(c.code,code)).findFirst();
        if (found.isPresent()) {
            return found.get().getDesc();
        }
        return "";
    }

    public static List<String> getCodeList(){
        return Arrays.stream(PaySceneEnum.values()).map(m->m.getCode()).collect(Collectors.toList());
    }

}
